package com.liveinstars.activity.business.activity.service.impl;

import com.liveinstars.activity.business.activity.repository.facade.IQuestionService;
import com.liveinstars.activity.business.activity.repository.po.Question;
import com.liveinstars.activity.business.activity.service.QuestionService;
import com.liveinstars.api.dto.QuestionDto;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 除了聚合根外聚合中还有领域服务service，也是主要的业务逻辑承载，负责聚合多个实体合作完成的业务逻辑，
 * 聚合中不要引用其他聚合的实体和值对象，以传参为主，为了以后拆分微服务，
 * 只用把应用接口层拆分出来。也不要调用其他聚合的领域服务，有application层调用
 */
@Service("questionService")
public class QuestionServiceImpl implements QuestionService {

    private final static Logger logger = LoggerFactory.getLogger(QuestionServiceImpl.class);

    @Autowired
    IQuestionService questionService;

    @Autowired
    QuestionFactory questionFactory;


    @Override
    public List<QuestionDto> getQuestions(Integer activityId) {
        List<Question> questions = questionService.getQuestions(activityId);
        List<QuestionDto> questionDtos = questionFactory.getQuestionsDto(questions);
        return questionDtos;
    }
}
